# nums = [1,2,3,1]
nums = [1,1,1,3,3,4,3,2,4,2]
# nums = [1,2,3,4]
def containsDuplicate(nums):
    #做一个字典，里面放两个桶：一个桶存放仅出现一次的元素，另一个桶放存在了多次的元素
    bucket=dict()
    bucket['onlyone']=set()
    # bucket['other']=set()

    for num in nums:
        # if num not in bucket['other'] and num not in bucket['onlyone']:
        if num not in bucket['onlyone']:
            #第一次出现
            bucket['onlyone'].add(num)
        elif num in bucket['onlyone']:
            #已经出现了一次了,再次出现，直接返回true
            # bucket['onlyone'].remove(num)
            return True
    return False
print(containsDuplicate(nums))